Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow interactive dismissal of VCs that need custom first responder handling #2536

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Amzd
Copy link
Collaborator

@Amzd Amzd commented Jan 19, 2025

Some View Controllers don't give back the first responder correctly (eg when you use the search bar in UIImagePickerController). To combat this we previously wrapped those in a custom view controller that just gave back the responders manually. That sadly had the side effect of disabling interactive dismissal (swipe down to dismiss).

This PR fixes the interactive dismiss by doing away with the custom view controller wrapper and instead swizzling the methods.

Swizzling is a bit controversial but it is used by Firebase which is in many apps, and the associated objects usage is already in our app because SDWebImage uses it too.

Copy link
Member

@r10s r10s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, i think, the added functionality, of being able to swipe-down-to-close the file-and gallery-view-controller as expected is worth the complexity. thanks a lot for diving into that and checking out options!

it is incredible, that this complexity is needed, but well, if there is no standard way, then it's that.

issues:

  • for the app-selector, swipe-down-to-close is still not working - is that expected?
  • the camera lost the swipe down functionality - is that expected?

also, i would like to hear from @zeitschlag if he would be fine with getting sth. like that in and if it is maybe better understandable by him :)

super.viewWillDisappear(animated)
if isBeingDismissed, !lastResponders.isEmpty, let newFirstResponder = UIResponder.currentFirstResponder {
@objc fileprivate func _viewWillDisappear(_ animated: Bool) {
_viewWillDisappear(animated)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not really understand what is happening here. at a first glance, this looks to me as a recursive call, but it is not and is working as expected.

but what is then called here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants